class ImageFile < ActiveRecord::Base
  has_one :media, :as => :mediable
  has_attachment :content_type => :image, 
                 :storage => :file_system, 
                 :max_size => 5.megabyte,
#                 :resize_to => '2500x2000>',
#                 :thumbnails => { :thumb => '200x200>', :medium => '600x600>', :large => '1024x768>' },
                 :processor => :rmagick
  validates_as_attachment

  def resize
    image_file = File.expand_path(RAILS_ROOT) + "/public" + public_filename
    job_key = MiddleMan.new_worker(:worker => :image_resize_worker, :job_key => "image"+self.id.to_s)
    worker  = MiddleMan.worker(:image_resize_worker,job_key)
    worker.do_work({:absolute_path => image_file, :image_id => self.id.to_s})
  end
end
